home *** CD-ROM | disk | FTP | other *** search
/ Best Tools for JAVA / Best Tools for JAVA.iso / JAVA_ALL / IDE / SUBARTIC / SUB_ARCT / CONSTRAI / CONSUMER.JAV < prev    next >
Encoding:
Text File  |  1996-10-04  |  2.2 KB  |  75 lines

  1. package sub_arctic.constraints;
  2.  
  3. /** 
  4.  * A small class to encapsulate a <value_consumer, part_number> pair. 
  5.  * @author Scott Hudson
  6.  */
  7. public class consumer_part_ref {
  8.  
  9.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  10.  
  11.   /** The consumer object. */
  12.   public value_consumer obj;
  13.  
  14.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  15.  
  16.   /** The part number of that object that we refer to */
  17.   public int part_num;
  18.  
  19.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  20.  
  21.   /** 
  22.    * Constructor. 
  23.    * @param value_consumer o  the object consuming the value
  24.    * @param int            pn the part within that object that makes use of 
  25.    *                          the value
  26.    */
  27.   public consumer_part_ref(value_consumer o, int pn)
  28.     {
  29.       obj = o;
  30.       part_num = pn;
  31.     }
  32.  
  33.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  34.  
  35.   /** Hash code so we can put these in hash tables. */
  36.   public int hashCode()
  37.     {
  38.       return obj.hashCode() ^ part_num;
  39.     }
  40.  
  41.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  42.  
  43.   /** Comparison operator. */
  44.   public boolean equals(Object other)
  45.     {
  46.       consumer_part_ref other_one;
  47.  
  48.       /* not equal to anything of the wrong type */
  49.       if (!(other instanceof consumer_part_ref)) return false;
  50.  
  51.       /* convert and test */
  52.       other_one = (consumer_part_ref)other;
  53.       return other_one.obj == obj && other_one.part_num == part_num;
  54.     }
  55.  
  56.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  57. }
  58.  
  59. /*=========================== COPYRIGHT NOTICE ===========================
  60.  
  61. This file is part of the subArctic user interface toolkit.
  62.  
  63. Copyright (c) 1996 Scott Hudson and Ian Smith
  64. All rights reserved.
  65.  
  66. The subArctic system is freely available for most uses under the terms
  67. and conditions described in 
  68.   http://www.cc.gatech.edu/gvu/ui/sub_arctic/sub_arctic/doc/usage.html 
  69. and appearing in full in the lib/interactor.java source file.
  70.  
  71. The current release and additional information about this software can be 
  72. found starting at: http://www.cc.gatech.edu/gvu/ui/sub_arctic/
  73.  
  74. ========================================================================*/
  75.